package com.zzzy.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import com.zzzy.po.User;

@Service
public class UserServiceImpl implements UserService {

	@Resource
    private JdbcTemplate jdbcTemplate;
	
	//JDBC 查询数据
    @Override
    public List<User> queryAllUser() {
        //SQL
        String sql = "SELECT *  FROM sys_user";
        //结果
        List<User> list = jdbcTemplate.query(sql, new RowMapper<User>() {
            //映射每行数据  
            @Override
            public User mapRow(ResultSet rs, int rowNum) throws SQLException {
            	User user = new User();
                user.setUsername(rs.getString("username"));

                return user;
            }

        });
        //返回结果
        return list;
    }


}
